﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WinForm101_Controls_Add_Remove
{
    public partial class Form1 : Form
    {
        Button button = new Button();

        public Form1()
        {
            InitializeComponent();
            button.Text = "Look at me";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if(!panel1.Contains(button)) panel1.Controls.Add(button);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if(panel1.Contains(button)) panel1.Controls.Remove(button);
        }
    }
}
